<?php
/**
 * 奖励管理
 */
class jiangliAction extends backendAction
{

    public function _initialize() {
        parent::_initialize();
        $this->_mod = D('jiangli_log');
        $this->_user = D('user');
        $this->_order = D('item_orders');
    }
	
	public function index() {
		import("ORG.Util.Page");
		$pc = 10;
		$count = $this->_mod->count('id');
        $pager = new Page($count, $pc);
        $select = $this->_mod->order('id DESC');
        $select->limit($pager->firstRow.','.$pager->listRows)->where(array('type'=>1));
        $page = $pager->show();
		$list = $select->select();
		
		foreach($list as $key=>$v){
			$userinfo = $this->_user->where(array('id'=>$v['uid']))->find();
			if($userinfo){
				$list[$key]['uid'] = $userinfo['truename'];
			}
		}
		$this->assign('page', $page);
		$this->assign('list', $list);
		$this->display();
	}
	public function mod(){
		$ref = array('code'=>0);
		$id = $this->_post('id', 'intval');
		$status = $this->_post('s', 'intval');
		
		$up_data = array();
		$up_data['status'] = $status;
		if($status==0)
			$up_data['s0time'] = time();
		if($status==1)
			$up_data['s1time'] = time();
		if($status==2)
			$up_data['s2time'] = time();
		
		$res = $this->_mod->where(array('id'=>$id))->save($up_data);
		if($res){
			$ref['code'] = 1;
		}
		echo json_encode($ref);
		exit();
	}
	
}